Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
How to add target="_blank" in location.assign()

In my JavaScript Project of Notes App, there is a location.assign() to my edit note page. But the problem is, whenever I click the note, it opens in the same tab as the index.html page. I have learned CSS and as far my knowledge, target="_blank" is used to open an anchor tag's link in a new window.

I want my edit.html page to open in a new window while also using location.assign().

Here is the code 👇

notes-app.js (using for managing the index.html page)

document.querySelector("#create-note").addEventListener("click", function (e) {
  const id = uuidv4();

  notes.push({
    id: id,
    title: "",
    body: "",
  });
  saveNotes(notes);
  location.assign(`/edit.html#${id}`);
});

index.html

<body>
    <h1>Notes App</h1>
    <h2>Take notes and never forget</h2>
    <input id="search-text" type="text" placeholder="Filter notes" />
    <select id="filter-by">
      <option value="byEdited">Sort by last edited</option>
      <option value="byCreated">Sort by recently created</option>
      <option value="alphabetical">Sort alphabetically</option>
    </select>
    <div id="notes"></div>
    <button id="create-note">Create Note</button>
    <script src="uuidv4.js"></script>
    <script src="notes-functions.js"></script>
    <script src="notes-app.js"></script>
  </body>

I did not include all the code and I hope that this is enough.

Thanks

Edit: If I need to, please write in comments that how do I transfer it to HTML meaning removing the location.assign() and adding something in the HTML or possibly CSS

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

document.querySelector("#create-note").addEventListener("click", 
  function (e) {
      window.open("http://www.someone.com/","_blank");
 });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda